<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<% String path=pageContext.getServletContext().getContextPath(); %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="<%=path %>/eazyui/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="<%=path %>/eazyui/themes/icon.css">
	<link rel="stylesheet" type="text/css" href="<%=path %>/eazyui/demo/demo.css">
	<script type="text/javascript" src="<%=path %>/eazyui/jquery.min.js"></script>
	<script type="text/javascript" src="<%=path %>/eazyui/jquery.easyui.min.js"></script>
	<style type="text/css">
	a{ color:#999; text-decoration:none;}
		a:hover{ text-decoration:underline;}
	#content{
		width:90%;
		padding:10px;
		margin:0 auto;
	}
	</style>
<title>Insert title here</title>
	<script type="text/javascript">

  <%--   function getPatientByPatient_idcard(patient_idcard,index){
    	var patient_idcard = $("#patient_idcard").val();
	      if(patient_idcard=='null'||patient_idcard==''){//get()表示将获取一组元素对象，转为数组
	         alert("请选择一个患者信息！");
	         return;
	      }else{
	    	  $.get("<%=path %>/patient/getPatientBypatient_idcard",{patient_idcard:patient_idcard},function(data,textStatus){
	  			
			
					
	    	  
	  			
	      })

	    } --%>
	
	
	function addPatient(){
		var card_id = $("#card_id").val();
		var patient_name = $("#patient_name").val();
		var patient_sex = $("#patient_sex").val();
		var patient_age = $("#patient_age").val();
		var patient_born = $("#patient_born").val();
		var patient_address = $("#patient_address").val();
		var patient_idcard = $("#patient_idcard").val();
		var patient_tel = $("#patient_tel").val();
		var patient_country = $("#patient_country").val();
		var patient_race = $("#patient_race").val();
		var patient_edu = $("#patient_edu").val();
		var patient_job = $("#patient_job").val();
		var patient_xuexing = $("#patient_xuexing").val();
		var patient_hunyin = $("#patient_hunyin").val();
		var patient_idaddress = $("#patient_idaddress").val();
		$.ajax({
			url:"<%=path %>/opreg/insertPatient",
			data:{card_id:card_id,patient_name:patient_name,patient_sex:patient_sex,patient_age:patient_age,
				patient_born:patient_born,patient_address:patient_address,patient_idcard:patient_idcard,
				patient_tel:patient_tel,patient_country:patient_country,patient_race:patient_race,
				patient_edu:patient_edu,patient_job:patient_job,patient_xuexing:patient_xuexing,patient_hunyin:patient_hunyin
				,patient_idaddress:patient_idaddress},
			/*dataType:"json",*/
			success:function(data,textStatus){
				if(textStatus=="success"){
					
					if(data==true){
						alert("添加成功");
						
						$('#dg').datagrid('appendRow',{
							card_id:card_id,
							patient_name:patient_name,
							patient_sex:patient_sex,
							patient_age:patient_age,
							patient_born:patient_born,
							patient_address:patient_address,
							patient_idcard:patient_idcard,
							patient_tel:patient_tel,
							patient_country:patient_country,
							patient_race:patient_race,
							patient_edu:patient_edu,
							patient_job:patient_job,
							patient_xuexing:patient_xuexing,
							patient_hunyin:patient_hunyin,
							patient_idaddress:patient_idaddress,
							
						});
						onLoadSuccess();
						$('#add').window("close");
					}
				}
			},
			error:function(data,textStatus){
				alert("error:"+textStatus);
			},
		})
		
	}
	function onLoadSuccess(){
		$("a[name='editbtn']").linkbutton({
			plain:true,
		    iconCls: 'icon-edit'
		});
		$("a[name='removebtn']").linkbutton({
			plain:true,
		    iconCls: 'icon-remove'
		});
	}

	
	</script>
</head>


<body>
<div id="content">
	<table class="easyui-datagrid" style="width:100%;" id="dg" data-options="onLoadSuccess:onLoadSuccess">
	<thead>
		<tr>
			<th field='card_id' style="width:6.5%;">卡号</th>
			<th field='patient_name' style="width:6.5%;">真实姓名</th>
			<th field='patient_sex' style="width:6.5%;">性别</th>
			<th field='patient_age' style="width:6.5%;">年龄</th>
			<th field='patient_born' style="width:6.5%;">出生日期</th>
			<th field='patient_address' style="width:7.75%;">家庭住址</th>
			<th field='patient_idcard' style="width:6.5%;">身份证号</th>
			<th field='patient_tel' style="width:6.5%;">电话号码</th>
			<th field='patient_country' style="width:6.5%;">国籍</th>
			<th field='patient_race' style="width:6.5%;">民族</th>
			<th field='patient_edu' style="width:6.5%;">教育程度</th>
			<th field='patient_job' style="width:6.5%;">从事职业</th>
			<th field='patient_xuexing' style="width:6.5%;">血型</th>
			<th field='patient_hunyin' style="width:6.5%;">婚姻状况</th>
			<th field='patient_idaddress' style="width:7.75%;">户籍所在地</th>
		</tr>
	</thead>
	<tbody>
	<c:forEach items="${patientList}" var="patient">
		<tr>
			<td>${patient.card_id}</td>
			<td>${patient.patient_name}</td>
			<td>${patient.patient_sex}</td>
			<td>${patient.patient_age}</td>
			<td>${patient.patient_born}</td>
			<td>${patient.patient_address}</td>
			<td>${patient.patient_idcard}</td>
			<td>${patient.patient_tel}</td>
			<td>${patient.patient_country}</td>
			<td>${patient.patient_race}</td>
			<td>${patient.patient_edu}</td>
			<td>${patient.patient_job}</td>
			<td>${patient.patient_xuexing}</td>
			<td>${patient.patient_hunyin}</td>
			<td>${patient.patient_idaddress}</td>
			
		</tr>
	</c:forEach>
	</tbody>
	
</table>
	<div style:"padding:20px;">
		<a href="#" class="easyui-linkbutton"  data-options="iconCls:'icon-add'" onclick="$('#add').window('open')">添加用户信息</a>&nbsp;	
		</div>
		<div id="add" class="easyui-window" title="Modal Window" data-options="modal:true,closed:true,iconCls:'icon-save'" style="width:600px;height:300px;padding:10px;">
						<div style="margin:0 auto;width:60%">
						<div>卡号:</div>
						<input class="easyui-textbox" id="card_id" style="width:100%;height:32px">
						</div>
						<div style="margin:0 auto;width:60%">
						<div>真实姓名：</div>
							<input class="easyui-textbox" id="patient_name" style="width:100%;height:32px;">
						</div>
						<div style="margin:0 auto;width:60%">
						<div>性别：</div>
							<select class="easyui-combobox" id="patient_sex" style="width:100%;height:32px;">
								<option value="0">男性</option>
								<option value="1">女性</option>
							</select>
						</div>
						<div style="margin:0 auto;width:60%">
						<div>年龄：</div>
							<input class="easyui-textbox" id="patient_age" style="width:100%;height:32px;">
						</div>
						<div style="margin:0 auto;width:60%">
						<div>出生日期：</div>
							<input class="easyui-textbox" id="patient_born" style="width:100%;height:32px;">
						</div>
						<div style="margin:0 auto;width:60%">
						<div>家庭住址：</div>
							<input class="easyui-textbox" id="patient_address" style="width:100%;height:32px;">
						</div>
						<div style="margin:0 auto;width:60%">
						<div>身份证号：</div>
							<input class="easyui-textbox" id="patient_idcard" style="width:100%;height:32px;">
						</div>
						<div style="margin:0 auto;width:60%">
						<div>电话号码：</div>
							<input class="easyui-textbox" id="patient_tel" style="width:100%;height:32px;">
						</div>
						<div style="margin:0 auto;width:60%">
						<div>国籍：</div>
							<input class="easyui-textbox" id="patient_country" style="width:100%;height:32px;">
						</div>
						<div style="margin:0 auto;width:60%">
						<div>民族：</div>
							<input class="easyui-textbox" id="patient_race" style="width:100%;height:32px;">
						</div>
						<div style="margin:0 auto;width:60%">
						<div>教育程度：</div>
							<input class="easyui-textbox" id="patient_edu" style="width:100%;height:32px;">
						</div>
						<div style="margin:0 auto;width:60%">
						<div>从事职业：</div>
							<input class="easyui-textbox" id="patient_job" style="width:100%;height:32px;">
						</div>
						<div style="margin:0 auto;width:60%">
						<div>血型：</div>
							<input class="easyui-textbox" id="patient_xuexing" style="width:100%;height:32px;">
						</div>
						<div style="margin:0 auto;width:60%">
						<div>婚姻状况：</div>
							<select class="easyui-combobox" id="patient_hunyin" style="width:100%;height:32px;">
								<option value="0">未婚</option>
								<option value="1">已婚</option>
							</select>
						</div>
						<div style="margin:0 auto;width:60%">
						<div>户籍所在地：</div>
							<input class="easyui-textbox" id="patient_idaddress" style="width:100%;height:32px;">
						</div>
						<div style="margin:0 auto;width:60%">
						<%-- <div>所属角色：</div>
							<select class="easyui-combobox" style="width:100%;height:32px;" id="editroleId">
								<c:forEach items="${roleList }" var="role">
									<option value="${role.role_id }" <c:if test="${role.role_id==role_id }">selected="selected"</c:if> >${role.role_name }</option>
								</c:forEach>
							</select>
						</div> --%>
					<div style="margin:0 auto;width:60%">
						<a href="#" class="easyui-linkbutton" iconCls="icon-ok" style="width:60%;height:32px;margin:5px auto;" onclick="addPatient()" >添加</a>
					</div>
				</div>
	</div>
	
	<!-- ******************************************************************************** -->
	
		<%-- 		<div class="panel panel-default">
			 
	        <div class="panel-body">
	        		<input class="easyui-textbox" type="text" name="patient_idcard" data-options="required:true"></input>
	                <a     class="btn btn-primary" href="javascript:void(0)" onclick="getPatientByPatient_idcard()">确定选择患者</a>
  					<!-- 日结账单明细-->
				   <table class="table table-striped">
			                   <tbody>
									<tr>
										 <th>序号</th><th>选择</th><th>姓名</th><th>身份证号码</th><th>年龄</th><th>性别</th> 
										 
			 						</tr>
			 						 
			 						 <c:forEach items="${rows}" var="patient" varStatus="i">
			 						   <tr>
			 						      <td>${i.count}</td>
			 						      <td>
			 						      <input type="radio" name="patient_idcard" value="${patient.patient_idcard}">
			 						      </td>
			 						      <td>${patient.name}</td>
			 						       <td>${patient.cardid}</td>
			 						       <td>${patient.age}</td>
			 						        <td>
			 						          <c:if test="${patient.sex==1}">男</c:if>
			 						           <c:if test="${patient.sex==0}">女</c:if>
			 						        </td>
			 						   </tr>
			 						 </c:forEach>
			 						 
			 						<%for(int i=0;i<list.size();i++){
			 						   PatientinfoEntity e=list.get(i);
			 						%>
			 						<tr>
										<td>
										<%=i %>
										</td>
										<td> 
										<%=e.getName() %>
					    				</td>
					    				<td>
					    				 <%=e.getIdnumber() %>
					    				</td> 
					    				<td>
					    				<%=e.getAge() %>
					    				</td>	 
									</tr>
									  						
			 						<% 
			 						} %>
									
										 
										 
									 
									 
							   </tbody>	
              	   </table>
		    </div>
		   </div> --%>
	
	
</body>
</html>